<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>服务单归档</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="resources/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="resources/css/public.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form">
    <blockquote class="layui-elem-quote quoteBox">
        <form class="layui-form">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input servCustName" placeholder="客户" />
                </div>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input servTitle" placeholder="概要" />
                </div>
                &nbsp;&nbsp;&nbsp;创建时间：
                <div class="layui-input-inline">
                    <input type="text" class="layui-input startTime" id="startTime" placeholder="起始时间" />
                </div>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input endTime" id="endTime" placeholder="结束时间" />
                </div>
                <div class="layui-input-inline">
                <select id="servType" name="servType" lay-verify="required">
                    <option value="">--服务单类型--</option>
                    <option value="3">咨询</option>
                    <option value="1">投诉</option>
                    <option value="2">建议</option>
                </select>
                </div>
                <div class="layui-input-inline">
                    <select id="servStatus" name="servStatus" lay-verify="required">
                        <option value="4">已反馈</option>
                        <option value="5">已归档</option>
                    </select>
                </div>
                <a class="layui-btn search_btn" data-type="reload" id="serchBtn">搜索</a>
            </div>
        </form>
        <input type="hidden" id="reanNames" th:value="${session.USER_SESSION.realname}"></input>
    </blockquote>
    <table id="serviceList" lay-filter="serviceList"></table>

    <!--操作-->
    <script type="text/html" id="usersListBar">

        <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="serviceFeedback">归档</a>
    </script>
</form>
<script type="text/javascript" src="resources/layui/layui.js"></script>
<script th:inline="none">
    layui.use(['form','layer','laydate','table','laytpl'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laydate = layui.laydate,
            laytpl = layui.laytpl,
            table = layui.table;
        //服务单列表
        laydate.render({
            elem: '#startTime',//指定元素
        });
        laydate.render({
            elem: '#endTime',//指定元素
        });
    //自动执行一次搜索
        setTimeout(function() {

            if(document.all) {
                document.getElementById("serchBtn").click();
            }

            else {
                var e = document.createEvent("MouseEvents");
                e.initEvent("click", true, true);
                document.getElementById("serchBtn").dispatchEvent(e);
            }
        }, 10);

        var tableIns = table.render({
            elem: '#serviceList',
            url : 'services',
            page : true,
            height : "full-125",
            limit : 20,
            limits : [10,15,20,25],
            id : "serviceListTable",
            cols : [[
                {type: "checkbox", fixed:"left"},
                {field: 'servNo', title: '编号',align:"center"},
                {field: 'servCustName', title: '客户',align:"center"},
                {field: 'servTitle', title: '概要',align:"center"},
                {field: 'servType', title: '类型',align:"center",templet:function(row){
                    if(row.servType==3){
                        return "咨询";
                    }else if(row.servType==1){
                        return "投诉";
                    }else if(row.servType==2){
                        return "建议";
                    }
                    }},
                {field: 'servStatus', title: '状态',align:"center",templet:function(row){
                        if(row.servStatus==1){
                            return "新创建";
                        }else if(row.servStatus==2){
                            return "已分配";
                        }else if(row.servStatus==3){
                            return "已处理";
                        }else if(row.servStatus==4){
                            return "已反馈";
                        }else if(row.servStatus==5){
                            return "已归档";
                        }
                    }},
                {field: 'servSatisfy', title: '评分',align:"center"},
                {field: 'servCreateBy', title: '创建人',align:"center"},
                {field: 'servCreateDate', title: '创建日期',align:"center"},
                {title: '操作', width:150, templet:'#usersListBar',fixed:"right",align:"center"}
            ]]
        });
        $(".search_btn").on("click",function(){
            table.reload("serviceListTable",{
                page: {
                    curr: 1 //重新从第 1 页开始
                },
                where: {
                    servCustName: $(".servCustName").val(),//搜索的关键字
                    servTitle: $(".servTitle").val(),  //搜索的关键字
                    startTime: $(".startTime").val(),  //搜索的关键字
                    endTime: $(".endTime").val(),  //搜索的关键字
                    servType: $("#servType").val(),  //搜索的关键字
                    servStatus: $("#servStatus").val(),
                    servDealName:$("#servDealName").val(),
                }
            })
        });

        table.on("tool(serviceList)",function (obj) {
            //获取当前行的数据
            var data=obj.data;
            switch (obj.event){

                case 'serviceFeedback':
                    serviceFeedback(data);
                    break;

            }
        });

        function serviceFeedback(data){
            var index=layui.layer.open({
                title:"服务单反馈",
                type:2,
                content:"toServiceFeedbackInner.do",
                success:function (layero,index) {
                    var body = layui.layer.getChildFrame('body', index);//少了这个是不能从父页面向子页面传值的
                    body.contents().find(".servNo").val(data.servNo);
                    body.contents().find(".servType").val(data.servType);
                    body.contents().find(".servTitle").val(data.servTitle);
                    body.contents().find(".servCustName").val(data.servCustName);
                    body.contents().find(".servStatus").val(data.servStatus);
                    body.contents().find(".servRequest").val(data.servRequest);
                    body.contents().find(".servCreateBy").val(data.servCreateBy);
                    body.contents().find(".servCreateDate").val(data.servCreateDate);
                    body.contents().find(".servDueTo").val(data.servDueTo);
                    body.contents().find(".servDueDate").val(data.servDueDate);
                    body.contents().find(".servDeal").val(data.servDeal);
                    body.contents().find(".servResult").val(data.servResult);
                    body.contents().find(".servSatisfy").val(data.servSatisfy);
                    body.contents().find(".custManagerName").val(data.customer.custManagerName);
                    body.contents().find(".custTelephone").val(data.customer.custTelephone);
                }
            });
            layui.layer.full(index);//全屏显示
        }

    })

</script>
</body>
</html>